import { wxLogin } from "@/api/login/login.js"
export default {
  data() {},
  methods: {},
  created() {
    if (wx.getStorageSync("allowLogin")) {
      uni.login({
        provider: "weixin",
        success: async (loginRes) => {
          const res = await wxLogin({
            code: loginRes.code,
            loginAuthType: 3,
            clientType: 3,
          })
          if (res.code === 200) {
            uni.setStorageSync("isLogin", true)
            uni.setStorageSync("token", res.data.token)
            uni.setStorageSync("userInfo", res.data)
            this.nickName = res.data.nickName
          } else {
            uni.showToast({
              title: "登录失败，请联系管理员",
              icon: "none",
            })
          }
        },
      })
    }
  },
}
